//
//  SSShopCarView.m
//  textDemo
//
//  Created by Esther on 2017/2/20.
//  Copyright © 2017年 Esther. All rights reserved.
//

#import "SSShopCarView.h"

@interface SSShopCarView()
@property(nonatomic, strong) UIButton *buyCarButton;
@property(nonatomic, strong) UIButton *addBuyCatButton;
@property(nonatomic, strong) UIButton *buyNowButton;
@property(nonatomic, strong) UIView *backView;

@end

@implementation SSShopCarView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.backView];
        
        [self addSubview:self.buyCarButton];
        [self addSubview:self.addBuyCatButton];
        [self addSubview:self.buyNowButton];
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    __weak typeof (self) weakSelf = self;
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weakSelf);
        
    }];
    [_buyCarButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(26, 26));
        make.left.equalTo(weakSelf.mas_left).offset(13);
        make.centerY.equalTo(weakSelf.mas_centerY);
        
    }];
    [_addBuyCatButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.height.equalTo(@70);
        make.left.equalTo(weakSelf.buyCarButton.mas_right).offset(35);
        make.right.equalTo(weakSelf.buyNowButton.mas_left).offset(30);
        
    }];
    [_buyNowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.height.equalTo(@70);
        make.width.equalTo(weakSelf.addBuyCatButton.mas_width);
        make.right.equalTo(weakSelf.mas_right).offset(15);
    }];
    
}

#pragma mark -
#pragma mark - 监听方法
- (void)buyCarMethod:(UIButton *)button{
    NSLog(@"%@",button);
}

#pragma mark -
#pragma mark - 懒加载

- (UIView *)backView{
    if (!_backView) {
        _backView = [[UIView alloc] init];
        _backView.backgroundColor = [UIColor whiteColor];
        
    }
    return _backView;
}
- (UIButton *)buyCarButton{
    if (!_buyCarButton) {
        _buyCarButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_buyCarButton setImage:[UIImage imageNamed:@"详情界面购物车按钮"] forState:(UIControlStateNormal)];
        
        [_buyCarButton addTarget:self action:@selector(buyCarMethod:) forControlEvents:(UIControlEventTouchUpInside)];
        
        
        
    }
    return _buyCarButton;
}

- (UIButton *)addBuyCatButton{
    if (!_addBuyCatButton) {
        _addBuyCatButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_addBuyCatButton setImage:[UIImage imageNamed:@"详情界面加入购物车按钮"] forState:(UIControlStateNormal)];
        [_addBuyCatButton addTarget:self action:@selector(buyCarMethod:) forControlEvents:(UIControlEventTouchUpInside)];
        
    }
    return _addBuyCatButton;
}

- (UIButton *)buyNowButton{
    if (!_buyNowButton) {
        _buyNowButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_buyNowButton setImage:[UIImage imageNamed:@"详情界面立即购买按钮"] forState:(UIControlStateNormal)];
        [_buyNowButton addTarget:self action:@selector(buyCarMethod:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _buyNowButton;
    
}

@end
